package com.wedo.mall.activity;

import android.os.Bundle;
import android.os.Handler;

import com.e.library.activity.EActivity;
import com.e.library.utils.ESPUtils;
import com.wedo.mall.R;

/**
 * Created by lxy on 2016/11/23.
 */

public class SplashActivity extends EActivity {
    @Override
    protected int layout() {
        return R.layout.activity_splash;
    }

    @Override
    protected void onActivityCreated(Bundle bundle) {
        //Login.isAutoLoginable(this);
        disableSwipeBack();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                toTarget();
            }
        },3000);

    }

    private void toTarget(){
        /**
         * 为了提高效率，先判断是否登录，因为
         * 1、自动登录的使用次数比较多
         * 2、登录页面使用次数比引导页次数多
         * 3、引导页使用次数仅一次
         */
//        if (Login.isLogined(SplashActivity.this)){
//            gotoActivity(MainActivity.class);
//        }else {
//            if (!ESPUtils.getBoolean(this,"to_guide",true)){
//                gotoActivity(LoginActivity.class);
//            }else {
//                gotoActivity(GuideActivity.class);
//            }
//        }

        if(!ESPUtils.getBoolean(this,"to_guide",true)){
            toActivity(MainActivity.class);
            defaultFinish();
        }else {
            toActivity(GuideActivity.class);
            defaultFinish();
        }
    }
}
